package com.zz.yt.test.delegate.pdf;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.whf.android.jar.base.delegate.BaseDelegate;
import com.whf.android.jar.util.log.LatteLogger;
import com.whf.android.jar.web.WebDelegateImpl;
import com.whf.android.jar.web.event.Event;
import com.whf.android.jar.web.event.EventManager;
import com.zz.yt.test.R;

/**
 * @Description WebView与js交互2调用
 * @Author: wuhf
 * @CreateDate: 2020/4/23 10:05
 * @Version: 1.0
 **/
public class PdfDocDelegate extends BaseDelegate {

    @NonNull
    public static PdfDocDelegate newInstance() {

        Bundle args = new Bundle();

        PdfDocDelegate fragment = new PdfDocDelegate();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected Object setLayout() {
        return R.layout.activity_pdf;
    }

    @Override
    protected void onBindView(@Nullable Bundle savedInstanceState, @NonNull View rootView) {
        addMarginTopEqualStatusBarHeight(findViewById(R.id.id_layout_frame));
        WebDelegateImpl delegate = WebDelegateImpl.create("file:///android_asset/index.html");
        delegate.setPageLoadListener(this);
        delegate.setTopDelegate(this);
        getSupportDelegate().loadRootFragment(R.id.id_layout_frame, delegate);

        EventManager.getInstance().addEvent("clickOnScan", new Event() {
            @Override
            public String execute(String params) {
                LatteLogger.i("调研扫一扫");
                return null;
            }
        });
    }


}
